package com.hucii.app.adapter;

import java.util.List;
import java.util.Map;

import com.hucii.app.R;
import com.hucii.app.entity.GridViewItemInfo;
import com.hucii.app.view.GridViewItemView;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class GridViewAdapter extends BaseAdapter {
	
	private Context mContext;
	private Map<Integer, Object> mMap;
	
	public GridViewAdapter(Context context, Map<Integer, Object> map) {
		this.mContext = context;
		this.mMap = map;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mMap.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		GridViewItemView gridViewItemView = null;
		if (null == convertView) {
			gridViewItemView = new GridViewItemView();
			LayoutInflater inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.main_ui_item, null);
			gridViewItemView.tv_gv_style_id = (TextView) convertView.findViewById(R.id.tv_gv_style_id);
			gridViewItemView.tv_gv_order_nums = (TextView) convertView.findViewById(R.id.tv_gv_order_nums);
			gridViewItemView.tv_gv_type = (TextView) convertView.findViewById(R.id.tv_gv_type);
			
			convertView.setTag(gridViewItemView);
		}else {
			gridViewItemView = (GridViewItemView) convertView.getTag();
		}
		GridViewItemInfo gridViewItemInfo = (GridViewItemInfo) mMap.get(position);
		gridViewItemView.getTv_gv_style_id().setText(gridViewItemInfo.getStyleId());
		gridViewItemView.getTv_gv_order_nums().setText(gridViewItemInfo.getOrderNums());
		gridViewItemView.getTv_gv_type().setText(gridViewItemInfo.getType());
		
		return convertView;
	}

}
